var app = getApp()
Page({
    data: {
      url:{
        comment :app.url.baseUrl+"/my/comment"
      },
      comments:[],
      pageNumber : -1,
      isPage : true,  //是事还有数据
    },
    onLoad: function (options) {
      this.getNextData()
    },
    onReachBottom:function(){
      this.getNextData()
    },
    getNextData:function(){
      var that = this
      if(!this.data.isPage){
       //提示
        return
      }
      var data = { pageNumber: this.data.pageNumber+1}
      var comments = this.data.comments
      app.ajax(this.data.url.comment,data,function(res){
        var d = res.data
        var b = true;
        if(d.data == null ||d.data.length<20)
          b= false;

        for(var i = 0;i<d.data.length;i++){
          var obj = d.data[i];
          comments.push(obj)
        }
        that.setData({ comments: comments,isPage:b,pageNumber:that.data.pageNumber+1})
      })
    },
    //刷新数据
    refreshData:function(){
      //初始化数据
      this.setData({ pageNumber: -1, comments: [], isPage:true});
      this.getNextData();
    },
    //预览用户回复图片
    preImg: function (e) {
      var src = e.currentTarget.dataset.imgadd;
      wx.previewImage({
        urls: [src],
      })
    }
})